package material.iteratorAndComponent;

import java.util.ArrayList;

public class PrintMenu {
    public static void main(String[] args) {
        /**
         * 早餐项是在一个ArrayList中
         */
        PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
        ArrayList breakfastakeHouseMenu = pancakeHouseMenu.getMenuItems();
        /**
         * 午餐项是在一个数组中
         */
        DinerMenu dinerMenu = new DinerMenu();
        MenuItem[] lunchItems = dinerMenu.getMenuItems();
        /**
         * 我们必须实现两个不同的for循环来处理这两个不同的菜单
         */
        for (int i = 0; i < breakfastakeHouseMenu.size(); i++) {
            MenuItem menuItem = (MenuItem) breakfastakeHouseMenu.get(i);
            System.out.print(menuItem.getName() + " ");
            System.out.println(menuItem.getPrice() + " ");
            System.out.println(menuItem.getDescription() + " ");
        }
        for (int i = 0; i < lunchItems.length; i++) {
            MenuItem menuItem = lunchItems[i];
            System.out.print(menuItem.getName() + " ");
            System.out.println(menuItem.getPrice() + " ");
            System.out.println(menuItem.getDescription() + " ");
        }
    }
}
